home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / graphics / 3dvect30.arj / QB.ARJ / MARCTAN.BAS next >
BASIC Source File  |  1993-10-28  |  3KB  |  110 lines

  1. a$ = "0123456789ABCDEF"
  2. w$ = "        dw  "
  3. s$ = "negtan:"
  4.  
  5. REM Make ArcTan tables for use in assembler
  6. REM use: qbasic marctan.bas>arctan.inc  to dump to disk
  7.  
  8. c = 0
  9. PRINT ";           public arctan"
  10. PRINT
  11. PRINT ";arctan:"
  12. PRINT ";           cmp ax,0"
  13. PRINT ";           jl s qd2or3"
  14. PRINT ";           cmp cx,0"
  15. PRINT ";           jge s halftax      ; quadrant 1"
  16. PRINT ";           neg cx             ; quadrant 4, ax=-ax"
  17. PRINT ";           call halftan"
  18. PRINT ";           neg ax"
  19. PRINT ";           shl ax,2"
  20. PRINT ";           ret"
  21. PRINT ";qd2or3:"
  22. PRINT ";           neg ax"
  23. PRINT ";           cmp cx,0"
  24. PRINT ";           jge s qd2"
  25. PRINT ";           neg cx             ; quad 3, ax=ax+8192"
  26. PRINT ";           call halftan"
  27. PRINT ";           add ax,8192"
  28. PRINT ";           shl ax,2"
  29. PRINT ";           ret"
  30. PRINT ";qd2:"
  31. PRINT ";           call halftan"
  32. PRINT ";           neg ax"
  33. PRINT ";           add ax,8192"
  34. PRINT ";           shl ax,2"
  35. PRINT ";           ret"
  36. PRINT ";halftax:"
  37. PRINT ";           call halftan"
  38. PRINT ";           shl ax,2"
  39. PRINT ";           ret"
  40. PRINT
  41. PRINT ";           align 4"
  42. PRINT
  43. PRINT ";halftan:"
  44. PRINT ";           movsx eax,ax"
  45. PRINT ";           movsx ecx,cx"
  46. PRINT ";           mov edx,0"
  47. PRINT
  48. PRINT ";; cx=rise  positive"
  49. PRINT ";; ax=run   positive"
  50. PRINT ";"
  51. PRINT ";           cmp eax,ecx"
  52. PRINT ";           jl s opptan        ; greater than 45 degrees, other side..."
  53. PRINT
  54. PRINT ";           xchg ecx,eax       ; ax<cx"
  55. PRINT ";           shl eax,11         ; *2048"
  56. PRINT ";           div ecx"
  57. PRINT ";           mov si,ax"
  58. PRINT ";           mov ax,w negtan[esi*2] ; resulting angle (0-512 is 0-45) in ax"
  59. PRINT ";           ret"
  60. PRINT
  61. PRINT ";           align 4"
  62. PRINT
  63. PRINT ";opptan:"
  64. PRINT ";           shl eax,11         ; *2048"
  65. PRINT
  66. PRINT ";           div ecx"
  67. PRINT ";           mov si,ax          ; ax remainder"
  68. PRINT ";           mov cx,w negtan[esi*2]"
  69. PRINT ";           mov ax,1000h"
  70. PRINT ";           sub ax,cx          ; resulting angle (2048-4096 is 45-90) in ax"
  71. PRINT ";           ret"
  72. PRINT
  73. PRINT s$
  74. PRINT w$;
  75.     
  76. FOR z = 0 TO 99.6 STEP 99.98 / 2048
  77.  
  78.  x = INT(ATN(z / 100) / 2 / 3.1415926535# * 1027 * 16)
  79.  
  80.  IF x = 256 THEN PRINT "100h"; : GOTO 78
  81.  
  82.  y = INT(x / 256)
  83.  
  84.  q$ = MID$(a$, y + 1, 1)
  85.                       
  86.  y = INT(x / 16) AND 15
  87.  
  88.  PRINT q$; MID$(a$, y + 1, 1); MID$(a$, (x / 16 - INT(x / 16)) * 16 + 1, 1); "h";
  89.  
  90. 78
  91.  
  92.  c = c + 1
  93.  IF c < 8 AND z < 99.55 THEN PRINT ","; : GOTO 91
  94.  IF z >= 99.55 THEN GOTO 91
  95.  c = 0
  96.  q = INT(z - 2.734)
  97.  u = INT(q * 1000) / 1000
  98.  
  99.  PRINT " ;"; u; "/100"
  100.  IF z > 99.55 THEN GOTO 99
  101.  
  102.  PRINT ; w$;
  103.  
  104. 91
  105.  
  106.  NEXT z
  107.  
  108. 99  END
  109.  
  110.